sessvars.game=sessvars.game||new Array();
sessvars.gahar = sessvars.gahar||new Array();
sessvars.game2=sessvars.game2||new Array();
sessvars.gahar2 = sessvars.gahar2||new Array();
sessvars.harga = sessvars.harga||0;
sessvars.mmb = sessvars.mmb||0;
sessvars.total = sessvars.total || 0; 
function hapus(nomin,arrayElement)
 {
	  toree = false;
 
 for(var i=0; i<sessvars.game.length;i++ )
   {    
  if(sessvars.game[i]==arrayElement && toree == false){
  sessvars.game.splice(i,1); 
  sessvars.gahar.splice(i,1);
  sessvars.harga -= nomin; 
  sessvars.total = sessvars.harga + (Math.ceil(sessvars.mmb/4200)*7000);
  toree = true;
  }
  } 
  $('#list2').text("");
  for (i=0;i < sessvars.game.length;i++)
{
$('#list2').append("-"+ sessvars.game[i] +" (Rp. "+sessvars.gahar[i]+" ) <img onClick='hapus("+sessvars.gahar[i]+",&quot;"+sessvars.game[i]+"&quot;);' src='http://1.bp.blogspot.com/-jN2sjH5eOHc/T0-jpoR1a6I/AAAAAAAAAPs/D_bIOmD7_PY/s400/button_delete.png' title='hapus'> <br>");
}   


  $('#Kaset2').text(sessvars.total);

  }
function ngecek(nomin,gamen){
	
sessvars.harga += nomin;
sessvars.game.push(gamen);
sessvars.gahar.push(nomin);
sessvars.total = sessvars.harga + (Math.ceil(sessvars.mmb/4200)*7000);
  $('#Kaset2').text(sessvars.total);

  
  $('#list2').text("");
  for (i=0;i < sessvars.game.length;i++)
{
$('#list2').append("-"+ sessvars.game[i] +" (Rp. "+sessvars.gahar[i]+" ) <img onClick='hapus("+sessvars.gahar[i]+",&quot;"+sessvars.game[i]+"&quot;);' src='http://1.bp.blogspot.com/-jN2sjH5eOHc/T0-jpoR1a6I/AAAAAAAAAPs/D_bIOmD7_PY/s400/button_delete.png' title='hapus'> <br>");
} 
}


$(document).ready(function () {
				$("#id_search").quicksearch("table tbody tr", {
					noResults: '#noresults',
					stripeRows: ['odd', 'even'],
					loader: 'span.loading'
				});
			});
  
function hapus2(nomin,arrayElement)
 {
	  toree = false;
 
 for(var i=0; i<sessvars.game2.length;i++ )
   {    
  if(sessvars.game2[i]==arrayElement && toree == false){
  sessvars.game2.splice(i,1); 
  sessvars.gahar2.splice(i,1);
  sessvars.mmb -= nomin; 
  sessvars.total = sessvars.harga + (Math.ceil(sessvars.mmb/4200)*7000);
  toree = true;
  }
  } 
  $('#list3').text("");
  for (i=0;i < sessvars.game2.length;i++)
{
$('#list3').append("-"+ sessvars.game2[i] +" ("+sessvars.gahar2[i]+" MB) <img onClick='hapus2("+sessvars.gahar2[i]+",&quot;"+sessvars.game2[i]+"&quot;);' src='http://1.bp.blogspot.com/-jN2sjH5eOHc/T0-jpoR1a6I/AAAAAAAAAPs/D_bIOmD7_PY/s400/button_delete.png' title='hapus'> <br>");
}   

  $('#Kaset').text(Math.ceil(sessvars.mmb/4200)*7000);
  $('#Kaset2').text(sessvars.total);
  $('#Kaset3').text(Math.ceil(sessvars.mmb/4200));
  $('#Kaset4').text(((Math.ceil((sessvars.mmb+1)/4200)*4200) - sessvars.mmb));
  }
function ngecek2(nomin,gamen){
	
sessvars.mmb += nomin;
sessvars.game2.push(gamen);
sessvars.gahar2.push(nomin);
sessvars.total = sessvars.harga + (Math.ceil(sessvars.mmb/4200)*7000);
  $('#Kaset').text(Math.ceil(sessvars.mmb/4200)*7000);
  $('#Kaset2').text(sessvars.total);
  $('#Kaset3').text(Math.ceil(sessvars.mmb/4200));
  $('#Kaset4').text(((Math.ceil((sessvars.mmb+1)/4200)*4200) - sessvars.mmb));
  
  $('#list4').text("");
  for (i=0;i < sessvars.game2.length;i++)
{
$('#list3').append("-"+ sessvars.game2[i] +" ("+sessvars.gahar2[i]+" MB) <img onClick='hapus2("+sessvars.gahar2[i]+",&quot;"+sessvars.game2[i]+"&quot;);' src='http://1.bp.blogspot.com/-jN2sjH5eOHc/T0-jpoR1a6I/AAAAAAAAAPs/D_bIOmD7_PY/s400/button_delete.png' title='hapus'> <br>");
} 
}

